<?php
use App\Http\Controllers\Admin\AdvController;
use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\CategoryController;
use App\Http\Controllers\Admin\ContentController;
use App\Http\Controllers\Admin\IndexController;
use App\Http\Controllers\Admin\AdvcontentController;
use App\Http\Controllers\UserController;
use App\Models\Admin\Admin;
use Illuminate\Support\Facades\Route;

Route::get('/', [App\Http\Controllers\IndexController::class, 'index'])->name('home');
Route::get('/lists/{id}', [App\Http\Controllers\IndexController::class,'lists'])->name('category');
Route::get('/detail/{id}', [App\Http\Controllers\IndexController::class,'detail'])->name('detail');
Route::get('/like/{id}', [App\Http\Controllers\IndexController::class,'like']);
Route::get('/comment', [App\Http\Controllers\IndexController::class,'comment']);
Route::post('/register', [UserController::class,'register']);
Route::post('/login', [UserController::class,'login']);
Route::get('/logout', [UserController::class,'logout']);


// 管理后台
Route::group(['prefix'=>'/admin'],function(){
    // 后台登录页面
    Route::get('/login',function (){
        return view('admin.login');
    });
    Route::post('/check',[AdminController::class,'check']);
    Route::get('/logout',[AdminController::class,'logout']);
    Route::get('/index',[IndexController::class, 'index']);
});



// 栏目管理
Route::group(['prefix'=>'/category'],function(){
    Route::get('/',[CategoryController::class,'index']);
    Route::get('/add',[CategoryController::class,'add']);
    Route::post('/save',[CategoryController::class,'save']);
    Route::get('edit/{id}', [CategoryController::class, 'edit']);
    Route::post('delete/{id}', [CategoryController::class, 'delete']);
    Route::post('update/{id}', [CategoryController::class, 'update']);
});

// 内容管理
Route::group(['prefix' => 'content'], function() {
    Route::get('/add', [ContentController::class, 'add']);
    Route::post('/save', [ContentController::class, 'save']);
    Route::post('/upload', [ContentController::class, 'upload']);
    Route::get('/{cid?}', [ContentController::class, 'index']);
    Route::get('/edit/{id}', [ContentController::class, 'edit']);
    Route::post('/update/{id}', [ContentController::class, 'update']);
    Route::post('/delete/{id}', [ContentController::class, 'delete']);
});


Route::group(['prefix'=>'/adv'],function(){
    Route::get('/',[AdvController::class, 'index']);
    Route::get('/add/{id?}',[AdvController::class, 'add']);
    Route::post('/save',[AdvController::class, 'save']);
    Route::post('/upload',[AdvController::class, 'upload']);
    Route::post('/delete',[AdvController::class, 'delete']);
    Route::get('/edit/{id}', [AdvController::class, 'add']); 
    
});

//广告列表
Route::group(['prefix' => 'advcontent'], function () {
    Route::get('/', [AdvcontentController::class, 'index']);
    Route::get('/add', [AdvcontentController::class, 'add']);
    Route::post('/save', [AdvcontentController::class, 'save']);
    Route::post('/upload', [AdvcontentController::class, 'upload']);
    Route::post('/delete/{id}', [AdvcontentController::class, 'delete']);
    Route::get('/edit/{id}', [AdvcontentController::class, 'add']); 
});
